package com.yrk.dao.impl;

import com.yrk.dao.EmpDao;
import com.yrk.entity.Emp;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcDaoSupport;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class EmpNamedSupportImpl extends NamedParameterJdbcDaoSupport implements EmpDao {

    @Override
    public List<Emp> getEmpAll() {
        return Collections.emptyList();
    }

    @Override
    public List<Emp> getEmpByName(String empName) {
        return Collections.emptyList();
    }

    @Override
    public int insertEmp(Emp emp) {
        String sql = "insert into emp(ename,job,sal) values(:ename,:job,:sal)";
        Map m = new HashMap();
        m.put("ename", emp.getEname());
        m.put("job", emp.getJob());
        m.put("sal", emp.getSal());
        return getNamedParameterJdbcTemplate().update(sql,m);
    }
}
